import java.io.File;
import java.text.SimpleDateFormat;

public class Main {
    public static void main(String[] args) {
        //遍历文件
        File dir = new File("D:/work");
        File[] names = dir.listFiles();
        for (File name:names) {
            System.out.println(name.getAbsolutePath());
        }


        //获取该文件最后修改的时间
        File file = new File("C:\\Users\\萧然春风\\Pictures\\Camera Roll\\美景.jpg");
        long time = file.lastModified();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(sdf.format(time));

    }
}
